// app.js
App({
  onLaunch() {
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  refreshToken(){
      if(this.globalData.isRefreshingToken) {
        return;
      };
      console.log('====刷新token=====');
      this.globalData.isRefreshingToken = true;
      wx.request({
        url: this.globalData.refreshTokenUrl,
        header:{
          "Accept-Encoding": "gzip, deflate, br",
          "Accept": "*/*",
          "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
          "Connection": "keep-alive"
        },
        data:{
          "email":"465144122@qq.com",
          "pass":"ChmLzj@123",
          "url":"https://zhizhangcs.cn/saveauth.php",
        },
        method:"POST",
        success:(res)=>{
          console.log('====刷新token====1111=');
          var results = res.data;
          console.log(results);
          this.globalData.isRefreshingToken = false;
        },
        fail: (err) => {
          this.globalData.isRefreshingToken = false;
        }
      })
  },

  globalData: {
    userInfo: null,
    isRefreshingToken:false,
    refreshTokenUrl:"https://vip.ylkny.com/test.php",
    //搜索请求
    searchUrl:"https://vip.ylkny.com/itra_search.php",//姓名查询
    mineData:"https://www.itra.run/api/Race/GetRaceResultsData",//用户赛事列表
    raceDetail:"https://www.itra.run/api/race/raceresults/",//赛事排行榜
    dataRunnerUrl:"https://www.itra.run/api/Runner/DataOfRunners/",//用户信息
    runnerResultUrl:"https://www.itra.run/api/RaceSearch/GetRaceSearch",//赛事搜索
    runnerRankUrl:"https://itrapi.tools.hk.cn/client/rank/runner",//排行榜
    itra_info:"https://zhizhangcs.cn/itra_info.php",//Token
    notice_url:"https://zhizhangcs.cn/itra_notice.php"
  }
})
